﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using CommonClasses;

namespace WpfCardGame.ViewModel
{
    class WarViewModel : ViewModelBase
    {
        private WarGame _game = new WarGame();
        public WarGame game
        {
            get
            {
                return _game;
            }
            set
            {
                _game = value;
                RaisePropertyChanged(() => game);
            }
        }

        private string name = "War";
        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
                RaisePropertyChanged(() => Name);
            }
        }

        private Card _PlayerCardInPlay;
        public Card PlayerCardInPlay
        {
            get
            {
                return _PlayerCardInPlay;
            }
            set
            {
                _PlayerCardInPlay = value;
                RaisePropertyChanged(() => PlayerCardInPlay);
            }
        }

        private RelayCommand _DealCommand;
        public RelayCommand DealCommand
        {
            get
            {
                if (_DealCommand == null)
                {
                    _DealCommand = new RelayCommand(
                        () => {game.Deal();
                                RaisePropertyChanged(() => game);},
                        () => true);
                }
                return _DealCommand;
            }
        }

        private RelayCommand _PlayerMove_Command;
        public RelayCommand PlayerMoveCommand
        {
            get
            {
                if (_PlayerMove_Command == null)
                {
                    _PlayerMove_Command = new RelayCommand(
                         () =>
                         {
                             PlayerMove();
                         },
                        () => true);
                }
                return _PlayerMove_Command;
            }
        }

        public void PlayerMove()
        {
            game.PlayerMove();
            RaisePropertyChanged(() => game);
        }

    }
}
